home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15505 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.cac.psu.edu!psuvm!f0o
  2. Organization: Penn State University
  3. Date: Fri, 19 Apr 1996 09:39:35 EDT
  4. From: Tim Benner <F0O@psuvm.psu.edu>
  5. Message-ID: <96110.093936F0O@psuvm.psu.edu>
  6. Newsgroups: comp.lang.c
  7. Subject: Array indexing with malloc
  8.  
  9. Hi netters!
  10.  
  11.    I write c programs to collect online data, and I always malloc a block
  12. of memory to hold the data.  I set the memory block up such that each
  13. row is a different time point, and each column is a different channel.
  14.    The formula I use to do this is:
  15.          RawData[CurrentPoint*NumChannels+Channel]
  16.    This works fine, except I don't like having to do the multiplication
  17. every time I want to access a point in the memory block.  I tried setting
  18. up the memory block by mallocing a structure.  This also works, and I
  19. believe is neater in implementation, but seems to have a limit of about
  20. 64k.  I allocate arrays of around 100k or more.
  21.    My burning question is, can I use a structure rather then the above
  22. method for accessing large arrays?  I'm using Turbo C++ version 3.0, and
  23. I'm in the large memory model.  I'm also setting the pointer to memory
  24. as a far huge pointer.
  25.  
  26. [Tim]
  27.